<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
  <a class="navbar-brand" >浙江机电大学</a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
      aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav mr-auto">
          <li class="nav-item active">
              <a class="nav-link" [routerLink]="['/home']">主页 <span class="sr-only">(current)</span></a>
          </li>

      </ul>
      <a class="btn btn-outline-success" [routerLink]="['/home']">返回</a>
  </div>
</nav>
<div class="d-flex justify-content-center ">
  <div class="d-flex align-items-center login-content">
    <form [formGroup]="myForm" (ngSubmit)="onSubmit(myForm.value)">
      <h3 class="d-flex justify-content-center">用户登录</h3>
      <div class="form-group">
        <label for="userName">用户名</label>
        <input type="text" class="form-control" id="userName" aria-describedby="输入用户名" name="userName"
          [formControl]="userName" [ngClass]="{'is-invalid':userName.invalid,'is-valid':userName.valid}">
        <div class="valid-feedback">
          用户名格式正确！
        </div>
        <div class="invalid-feedback">
          <span *ngIf="userName.hasError('required')">用户名必须填写!</span>
          <span
            *ngIf="!userName.hasError('required') && !userName.hasError('invalidUser') && userName.hasError('minlength')">用户名至少3位！</span>
          <span
            *ngIf="!userName.hasError('required') && !userName.hasError('invalidUser') && userName.hasError('maxlength')">用户名最多20位！</span>
        </div>
      </div>
      <div class="form-group">
        <label for="password">密码</label>
        <input type="password" class="form-control" id="password" name="password" [formControl]="password"
          [ngClass]="{'is-invalid': password.invalid , 'is-valid': password.valid}">
        <div class="valid-feedback">密码格式正确！</div>
        <div class="invalid-feedback">
          <span *ngIf="password.hasError('required')">密码必须填写！</span>
          <span *ngIf="!password.hasError('required') && password.hasError('minlength')">密码至少6位！</span>
          <span *ngIf="!password.hasError('required') && password.hasError('maxlength')">密码最多16位！</span>
        </div>
      </div>
      <div>
        <button type="submit" class="btn btn-dark btn-block ">登录</button>
      </div>
      
    </form>
  </div>
</div>